package com.example.product.grpc;

import com.example.UserProto;
import com.example.UserServiceGrpc;
import io.grpc.stub.StreamObserver;
import org.springframework.stereotype.Service;

@Service
public class LoginService extends UserServiceGrpc.UserServiceImplBase {
    @Override
    public void login(UserProto.UserRequest request, StreamObserver<UserProto.UserResponse> responseObserver) {
        String name = request.getName();
        String password = request.getPassword();
        System.out.printf("name:" + name + " password:" + password);

        UserProto.UserDataResponse userDataResponse = UserProto.UserDataResponse.newBuilder()
                .setContent("我收了以")
                .build();

        UserProto.UserResponse response = UserProto.UserResponse.newBuilder()
                .addResult("2")
                .addResult("3")
                .addResult("4")
                .setData(userDataResponse).build();

        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
